import matplotlib.pyplot as plt
import matplotlib
import matplotlib
import np
from matplotlib.patches import Ellipse

font = {'size':26}
matplotlib.rc('font', **font)
markersize = 18


def parse_file(filename):
    infile = open(filename, "r")
    thresh = []
    f1_score = []
    are = []
    for line in infile:
        line = line.strip()
        items = line.split(" ")
        if "thresh" in items[0]:
            thresh.append(int(items[1]))
        if "f1_score_of_heavy_hitter_detection:" == items[0]:
            f1_score.append(float(items[1]))
        if "are_of_heavy_hitters:" == items[0]:
            are.append(float(items[1]))
    infile.close()
    return thresh, f1_score, are

if __name__ == "__main__":
########## For CAIDA trace 50K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_caida_HashFlow_50K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_caida_HashPipe_50K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_caida_ElasticSketch_50K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_caida_FlowRadar_50K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("F1 Score")
    plt.savefig("caida_50K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("caida_50K_f1_score.png", bbox_inches = "tight")
    plt.savefig("caida_50K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("ARE")
    plt.savefig("caida_50K_re.pdf", bbox_inches = "tight")
    plt.savefig("caida_50K_re.png", bbox_inches = "tight")
    plt.savefig("caida_50K_re.eps", bbox_inches = "tight")
    plt.close()

########## For CAIDA trace 100K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_caida_HashFlow_100K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_caida_HashPipe_100K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_caida_ElasticSketch_100K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_caida_FlowRadar_100K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("F1 Score")
    plt.savefig("caida_100K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("caida_100K_f1_score.png", bbox_inches = "tight")
    plt.savefig("caida_100K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("ARE")
    plt.savefig("caida_100K_re.pdf", bbox_inches = "tight")
    plt.savefig("caida_100K_re.png", bbox_inches = "tight")
    plt.savefig("caida_100K_re.eps", bbox_inches = "tight")
    plt.close()

########## For CAIDA trace 150K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_caida_HashFlow_150K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_caida_HashPipe_150K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_caida_ElasticSketch_150K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_caida_FlowRadar_150K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("F1 Score")
    plt.savefig("caida_150K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("caida_150K_f1_score.png", bbox_inches = "tight")
    plt.savefig("caida_150K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("ARE")
    plt.savefig("caida_150K_re.pdf", bbox_inches = "tight")
    plt.savefig("caida_150K_re.png", bbox_inches = "tight")
    plt.savefig("caida_150K_re.eps", bbox_inches = "tight")
    plt.close()

########## For CAIDA trace 200K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_caida_HashFlow_200K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_caida_HashPipe_200K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_caida_ElasticSketch_200K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_caida_FlowRadar_200K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("F1 Score")
    plt.savefig("caida_200K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("caida_200K_f1_score.png", bbox_inches = "tight")
    plt.savefig("caida_200K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("ARE")
    plt.savefig("caida_200K_re.pdf", bbox_inches = "tight")
    plt.savefig("caida_200K_re.png", bbox_inches = "tight")
    plt.savefig("caida_200K_re.eps", bbox_inches = "tight")
    plt.close()

########## For CAIDA trace 250K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_caida_HashFlow_250K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_caida_HashPipe_250K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_caida_ElasticSketch_250K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_caida_FlowRadar_250K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markerfacecolor="none", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markerfacecolor="none", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markerfacecolor="none", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markerfacecolor="none", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold in Pkts")
    plt.ylabel("F1 Score")
    plt.savefig("caida_250K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("caida_250K_f1_score.png", bbox_inches = "tight")
    plt.savefig("caida_250K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markerfacecolor="none", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markerfacecolor="none", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markerfacecolor="none", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markerfacecolor="none", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold in Pkts")
    plt.ylabel("ARE")
    plt.ylim(-0.05, 1.5)
    plt.savefig("caida_250K_re.pdf", bbox_inches = "tight")
    plt.savefig("caida_250K_re.png", bbox_inches = "tight")
    plt.savefig("caida_250K_re.eps", bbox_inches = "tight")
    plt.close()


########## For Tsinghua trace 50K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_tsinghua_HashFlow_50K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_tsinghua_HashPipe_50K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_tsinghua_ElasticSketch_50K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_tsinghua_FlowRadar_50K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("F1 Score")
    plt.savefig("tsinghua_50K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("tsinghua_50K_f1_score.png", bbox_inches = "tight")
    plt.savefig("tsinghua_50K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("ARE")
    plt.savefig("tsinghua_50K_re.pdf", bbox_inches = "tight")
    plt.savefig("tsinghua_50K_re.png", bbox_inches = "tight")
    plt.savefig("tsinghua_50K_re.eps", bbox_inches = "tight")
    plt.close()

########## For Tsinghua trace 100K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_tsinghua_HashFlow_100K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_tsinghua_HashPipe_100K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_tsinghua_ElasticSketch_100K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_tsinghua_FlowRadar_100K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("F1 Score")
    plt.savefig("tsinghua_100K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("tsinghua_100K_f1_score.png", bbox_inches = "tight")
    plt.savefig("tsinghua_100K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("ARE")
    plt.savefig("tsinghua_100K_re.pdf", bbox_inches = "tight")
    plt.savefig("tsinghua_100K_re.png", bbox_inches = "tight")
    plt.savefig("tsinghua_100K_re.eps", bbox_inches = "tight")
    plt.close()

########## For Tsinghua trace 150K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_tsinghua_HashFlow_150K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_tsinghua_HashPipe_150K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_tsinghua_ElasticSketch_150K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_tsinghua_FlowRadar_150K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("F1 Score")
    plt.savefig("tsinghua_150K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("tsinghua_150K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("ARE")
    plt.savefig("tsinghua_150K_re.pdf", bbox_inches = "tight")
    plt.savefig("tsinghua_150K_re.png", bbox_inches = "tight")
    plt.savefig("tsinghua_150K_re.eps", bbox_inches = "tight")
    plt.close()

########## For Tsinghua trace 200K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_tsinghua_HashFlow_200K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_tsinghua_HashPipe_200K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_tsinghua_ElasticSketch_200K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_tsinghua_FlowRadar_200K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("F1 Score")
    plt.savefig("tsinghua_200K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("tsinghua_200K_f1_score.png", bbox_inches = "tight")
    plt.savefig("tsinghua_200K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("ARE")
    plt.savefig("tsinghua_200K_re.pdf", bbox_inches = "tight")
    plt.savefig("tsinghua_200K_re.png", bbox_inches = "tight")
    plt.savefig("tsinghua_200K_re.eps", bbox_inches = "tight")
    plt.close()

########## For Tsinghua trace 250K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_tsinghua_HashFlow_250K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_tsinghua_HashPipe_250K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_tsinghua_ElasticSketch_250K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_tsinghua_FlowRadar_250K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markerfacecolor="none", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markerfacecolor="none", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markerfacecolor="none", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markerfacecolor="none", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold in Pkts")
    plt.ylabel("F1 Score")
    plt.savefig("tsinghua_250K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("tsinghua_250K_f1_score.png", bbox_inches = "tight")
    plt.savefig("tsinghua_250K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markerfacecolor="none", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markerfacecolor="none", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markerfacecolor="none", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markerfacecolor="none", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold in Pkts")
    plt.ylabel("ARE")
    plt.ylim(-0.05, 1.5)
    plt.savefig("tsinghua_250K_re.pdf", bbox_inches = "tight")
    plt.savefig("tsinghua_250K_re.png", bbox_inches = "tight")
    plt.savefig("tsinghua_250K_re.eps", bbox_inches = "tight")
    plt.close()

########## For Telecom trace 50K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_telecom_HashFlow_50K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_telecom_HashPipe_50K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_telecom_ElasticSketch_50K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_telecom_FlowRadar_50K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("F1 Score")
    plt.savefig("telecom_50K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("telecom_50K_f1_score.png", bbox_inches = "tight")
    plt.savefig("telecom_50K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("ARE")
    plt.savefig("telecom_50K_re.pdf", bbox_inches = "tight")
    plt.savefig("telecom_50K_re.png", bbox_inches = "tight")
    plt.savefig("telecom_50K_re.eps", bbox_inches = "tight")
    plt.close()

########## For Telecom trace 100K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_telecom_HashFlow_100K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_telecom_HashPipe_100K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_telecom_ElasticSketch_100K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_telecom_FlowRadar_100K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("F1 Score")
    plt.savefig("telecom_100K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("telecom_100K_f1_score.png", bbox_inches = "tight")
    plt.savefig("telecom_100K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("ARE")
    plt.savefig("telecom_100K_re.pdf", bbox_inches = "tight")
    plt.savefig("telecom_100K_re.png", bbox_inches = "tight")
    plt.savefig("telecom_100K_re.eps", bbox_inches = "tight")
    plt.close()

########## For Telecom trace 150K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_telecom_HashFlow_150K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_telecom_HashPipe_150K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_telecom_ElasticSketch_150K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_telecom_FlowRadar_150K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("F1 Score")
    plt.savefig("telecom_150K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("telecom_150K_f1_score.png", bbox_inches = "tight")
    plt.savefig("telecom_150K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("ARE")
    plt.savefig("telecom_150K_re.pdf", bbox_inches = "tight")
    plt.savefig("telecom_150K_re.eps", bbox_inches = "tight")
    plt.close()

########## For Telecom trace 200K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_telecom_HashFlow_200K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_telecom_HashPipe_200K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_telecom_ElasticSketch_200K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_telecom_FlowRadar_200K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("F1 Score")
    plt.savefig("telecom_200K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("telecom_200K_f1_score.png", bbox_inches = "tight")
    plt.savefig("telecom_200K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("ARE")
    plt.savefig("telecom_200K_re.pdf", bbox_inches = "tight")
    plt.savefig("telecom_200K_re.png", bbox_inches = "tight")
    plt.savefig("telecom_200K_re.eps", bbox_inches = "tight")
    plt.close()

########## For Telecom trace 250K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_telecom_HashFlow_250K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_telecom_HashPipe_250K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_telecom_ElasticSketch_250K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_telecom_FlowRadar_250K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", markerfacecolor="none", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", markerfacecolor="none", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", markerfacecolor="none", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", markerfacecolor="none", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold in Pkts")
    plt.ylabel("F1 Score")
    plt.savefig("telecom_250K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("telecom_250K_f1_score.png", bbox_inches = "tight")
    plt.savefig("telecom_250K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markerfacecolor="none", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markerfacecolor="none", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markerfacecolor="none", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markerfacecolor="none", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold in Pkts")
    plt.ylabel("ARE")
    plt.ylim(-0.05, 1.5)
    plt.savefig("telecom_250K_re.pdf", bbox_inches = "tight")
    plt.savefig("telecom_250K_re.png", bbox_inches = "tight")
    plt.savefig("telecom_250K_re.eps", bbox_inches = "tight")
    plt.close()

########## For HGC trace 50K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_hgc_HashFlow_50K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_hgc_HashPipe_50K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_hgc_ElasticSketch_50K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_hgc_FlowRadar_50K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("F1 Score")
    plt.savefig("hgc_50K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("hgc_50K_f1_score.png", bbox_inches = "tight")
    plt.savefig("hgc_50K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("ARE")
    plt.savefig("hgc_50K_re.pdf", bbox_inches = "tight")
    plt.savefig("hgc_50K_re.png", bbox_inches = "tight")
    plt.savefig("hgc_50K_re.eps", bbox_inches = "tight")
    plt.close()

########## For HGC trace 100K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_hgc_HashFlow_100K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_hgc_HashPipe_100K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_hgc_ElasticSketch_100K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_hgc_FlowRadar_100K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("F1 Score")
    plt.savefig("hgc_100K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("hgc_100K_f1_score.png", bbox_inches = "tight")
    plt.savefig("hgc_100K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("ARE")
    plt.savefig("hgc_100K_re.pdf", bbox_inches = "tight")
    plt.savefig("hgc_100K_re.png", bbox_inches = "tight")
    plt.savefig("hgc_100K_re.eps", bbox_inches = "tight")
    plt.close()

########## For HGC trace 150K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_hgc_HashFlow_150K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_hgc_HashPipe_150K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_hgc_ElasticSketch_150K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_hgc_FlowRadar_150K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("F1 Score")
    plt.savefig("hgc_150K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("hgc_150K_f1_score.png", bbox_inches = "tight")
    plt.savefig("hgc_150K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("ARE")
    plt.savefig("hgc_150K_re.pdf", bbox_inches = "tight")
    plt.savefig("hgc_150K_re.png", bbox_inches = "tight")
    plt.savefig("hgc_150K_re.eps", bbox_inches = "tight")
    plt.close()

########## For HGC trace 200K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_hgc_HashFlow_200K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_hgc_HashPipe_200K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_hgc_ElasticSketch_200K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_hgc_FlowRadar_200K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("F1 Score")
    plt.savefig("hgc_200K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("hgc_200K_f1_score.png", bbox_inches = "tight")
    plt.savefig("hgc_200K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold")
    plt.ylabel("ARE")
    plt.savefig("hgc_200K_re.pdf", bbox_inches = "tight")
    plt.savefig("hgc_200K_re.png", bbox_inches = "tight")
    plt.savefig("hgc_200K_re.eps", bbox_inches = "tight")
    plt.close()

########## For HGC trace 250K ########
    hf_thresh, hf_f1_score, hf_are = parse_file("./res_hgc_HashFlow_250K.txt")
    hp_thresh, hp_f1_score, hp_are = parse_file("./res_hgc_HashPipe_250K.txt")
    es_thresh, es_f1_score, es_are = parse_file("./res_hgc_ElasticSketch_250K.txt")
    fr_thresh, fr_f1_score, fr_are = parse_file("./res_hgc_FlowRadar_250K.txt")

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_f1_score, label = "HF", marker = "x", markerfacecolor="none", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_f1_score, label = "HP", marker = "^", markerfacecolor="none", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_f1_score, label = "ES", marker = "<", markerfacecolor="none", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_f1_score, label = "FR", marker = "o", markerfacecolor="none", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold in Pkts")
    plt.ylabel("F1 Score")
    plt.ylim(-0.05, 1.5)
    plt.savefig("hgc_250K_f1_score.pdf", bbox_inches = "tight")
    plt.savefig("hgc_250K_f1_score.png", bbox_inches = "tight")
    plt.savefig("hgc_250K_f1_score.eps", bbox_inches = "tight")
    plt.close()

    plt.figure()
#    plt.xticks(range(0, 250001, 50000), ("0", "50K", "100K", "150K", "200K", "250K"))
    plt.plot(hf_thresh, hf_are, label = "HF", marker = "x", markerfacecolor="none", markersize=markersize, color = 'blue')
    plt.plot(hp_thresh, hp_are, label = "HP", marker = "^", markerfacecolor="none", markersize=markersize, color = 'red')
    plt.plot(es_thresh, es_are, label = "ES", marker = "<", markerfacecolor="none", markersize=markersize, color = 'green')
    plt.plot(fr_thresh, fr_are, label = "FR", marker = "o", markerfacecolor="none", markersize=markersize, color = 'purple')
    plt.legend(bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), loc = 3, ncol = 2, mode = "expand", borderaxespad = 0.0)
    plt.xlabel("Threshold in Pkts")
    plt.ylabel("ARE")
    plt.savefig("hgc_250K_re.pdf", bbox_inches = "tight")
    plt.savefig("hgc_250K_re.png", bbox_inches = "tight")
    plt.savefig("hgc_250K_re.eps", bbox_inches = "tight")
    plt.close()


